#include <iostream>  
using namespace std;  
typedef int ElemType;  
typedef struct  
{  
    ElemType *base;  
    int front;  
    int rear;  
    int MAXSIZE;  
}SqQueue;  
  
void InitQueue(SqQueue& Q,int n)  
{  
    Q.base = new ElemType[100];  
    Q.front=Q.rear=0;  
    Q.MAXSIZE = n+1;
}  
  
  
bool EnQueue(SqQueue& Q,ElemType e)  
{  
    if((Q.rear+1)%Q.MAXSIZE==Q.front)  
    {  
         
        return false;  
    }  
    Q.base[Q.rear] = e;  
    Q.rear = (Q.rear+1)%Q.MAXSIZE;  
    return true;  
}  
  
bool DeQueue(SqQueue& Q,ElemType& e)  
{  
    if(Q.front==Q.rear)  
    {  
        return false;  
    }  
    e = Q.base[Q.front];  
    Q.base[Q.front] = 0;  
    Q.front = (Q.front+1)%(Q.MAXSIZE-1);
    return true;  
}  
int main()  
{  
    int n,m,i=1,a[100],k=0;  
    SqQueue Q;  
    ElemType e;  
    cin>>n>>m;  
	if(m>n){
		cout<<"error!";
		return 0;
	}

    InitQueue(Q,n);  
    while(i<=n)
    {  
        EnQueue(Q,i);  
        i++;  
    }   

    int Count = n; 
    while(Count != 1)  
    {  
        i = 1;
        while(i != m) 
        {  
            Q.front = (Q.front+1)%(Q.MAXSIZE-1); 
            if(Q.base[Q.front] != 0) 
            {  
                i++;  
            }  
        }  
        DeQueue(Q,e);  
        while(Q.base[Q.front] == 0)  
        {  
            Q.front = (Q.front+1)%(Q.MAXSIZE-1);  
        }  
        a[k++]=e;
        Count--;  
    }  
    DeQueue(Q,e); 
    a[k++]=e;
	for(i=0;i<k;i++){
		if(i==k-1)
		cout<<a[i];
		else
		cout<<a[i]<<" ";
	}  
}  
